#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 114514;
int t;
int n,m,l,V,answer2;
int d[N],v[N],a[N],vis[N];
int p[N],qp[N],qd[N];
int pp[N];
vector<int> g[N];
bool check(int c,int x){
    if(p[x] < d[c]) return 0;
    int vv = (p[x] - d[c]) * a[c] * 2 + v[c] * v[c];
    if(vv > V * V) return 1;
    return 0;
}
void dfs(int dep,int sum){
    if(dep > m){
        memset(vis,0,sizeof(vis));
        //for(int i = 1;i <= m;i ++ ) cout << pp[i];
        //cout << endl;
        for(int i = 1;i <= m;i ++ ){
            if(pp[i]){
                for(int j = 1;j <= n;j ++ ){
                    //cout << qp[j] << " " << qd[j] << " " << p[i] << endl;
                    if(qd[j] == 0 && qp[j] == 0) continue;
                    if(qp[j] <= i && qd[j] >= i){
                        vis[j] = 1;
                    }
                }
            }
        }
        for(int i = 1;i <= n;i ++ ){
            if(qd[i] == 0 && qp[i] == 0) continue;
            //cout << vis[i];
        }
        //cout<<endl;
        for(int i = 1;i <= n;i ++ ){
            if(qd[i] == 0 && qp[i] == 0) continue;
            if(!vis[i]) return ;
        }
        //cout << sum << endl;
        answer2 = min(answer2,sum);
        return ;
    }
    pp[dep] = 1;
    dfs(dep + 1,sum + 1);
    pp[dep] = 0;
    dfs(dep + 1,sum);
}
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin >> t;
    while(t--){
        memset(qp,0,sizeof(qp));
        cin >> n >> m >> l >> V;
        bool flag = 1;
        for(int i = 1;i <= n;i ++ ){
            cin >> d[i] >> v[i] >> a[i];
        }
        for(int i = 1;i <= m;i ++){
            cin >> p[i];
        }
        int answer1 = 0;
        int cc = 0;
        for(int i = 1;i <= n;i ++ ){
            int lft = 1,rgt = m;
            int cnt = -1;
            if(a[i] >= 0){
                while(lft <= rgt){
                    int mid = lft + rgt >> 1;
                    if(check(i,mid)){
                        rgt = mid - 1;
                        cnt = mid;
                    }
                    else{
                        lft = mid + 1;
                    }
                }
                if(cnt != -1){
                    qp[i] = cnt;
                    qd[i] = m;
                }
            }
            else {
                flag = 0;
                lft = lower_bound(p + 1,p + m + 1,d[i]) - p;
                if(lft > m) continue;
                int cnt1 = lft;
                if(!check(i,cnt1)) continue;
                cnt = cnt1;
                while(lft <= rgt){
                    int mid = lft + rgt >> 1;
                    if(check(i,mid)){
                        lft = mid + 1;
                        cnt = mid;
                    }
                    else{
                        rgt = mid - 1;
                    }
                }
                qp[i] = cnt1;
                qd[i] = cnt;
            }
            if(cnt != -1){
                //cout << cnt << endl;
                answer1 ++ ;
            }
        }
        /*
        for(int i = 1;i <= cc;i ++ ){
            cout << qp[i] << " " << qd[i] << endl;
        }
        */
        cout << answer1 << " ";
        if(flag){
            if(answer1 == 0) cout << m << endl;
            else cout << m - 1 << endl;
        }
        else{
            answer2 = m;
            dfs(1,0);
            cout << m - answer2 << endl;
        }
    }
}